using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace ADiKt {
    class BackgroundScreen : Screen {
        ContentManager content;
        Texture2D backgroundTexture;

        /// <summary> the background image as a screen </summary>
        public BackgroundScreen() {
            TransitionOnTime = TimeSpan.FromSeconds(0.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);
        }

        /// <summary> loads the backgorund into the joint content manager </summary>
        public override void LoadContent() {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            backgroundTexture = content.Load<Texture2D>("MenuBg");
        }

        /// <summary> unloads all content for this screen, relesing the memory </summary>
        public override void UnloadContent() {
            content.Unload();
        }

        /// <summary> 
        /// updates the screen for transitions on/off as it's the 
        /// background it is always suposed to be covered, but not hidden
        /// so this property is overridden
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) {
            base.Update(gameTime, otherScreenHasFocus, false);
        }

        /// <summary> draws the background to the screen </summary>
        public override void Draw(GameTime gameTime) {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            Rectangle fullscreen = new Rectangle(0, 0, viewport.Width, viewport.Height);

            spriteBatch.Begin();
            spriteBatch.Draw(backgroundTexture, fullscreen, new Color(TransitionAlpha, TransitionAlpha, TransitionAlpha));
            spriteBatch.End();
        }
    }
}
